package com.hc.util;

import com.hc.bean.Dot;




public class GetCenterDotUtil {


	public static Dot getCenterDot(double aX,double aY,double cX,double cY,double p1,double p2){
		double h  = 0,j  = 0,z  = 0,k = 0,n = 0,y = 0,x = 0,a = 0,b = 0;
		
		if((aY==cY)&&(aX!=cX)){
			y = aY;
			if(cX>aX){
				
			 x = aX+p1;
			 
			}else{
				
			 x = aX-p1;
				
			}
			
			
		}else if((aX==cX)&&(aY!=cY)){
			x = aX;
			if(cY>aY){
				
			 y = aY+p1;
			}else{
				
			 y = aY-p1;
				
			}
			
			
		}else if((aX==cX)&&(aY==cY)){
			
			x= aX;
			y = aY;
		}else{
			
			h = aX*aX+ aY*aY;
			j = cY*cY+cX*cX ;
			z = p1*p1 - p2*p2;
			a = 2*cX -2*aX; 
			b= 2*cY-2*aY ; 
			 k =(cY-aY)/(cX-aX);
			n = cY - k*cX;
			x = (z+j-h-n*b)/(k*b+a);
			y=((z+j-h-n*b)/(k*b+a))*k +n;
		}
		
		
		
		
		return new Dot(x, y); 
		
		

	}
	


}


